<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title></title>
  </head>
  <body>

    书名:<input type="text"  id="sm" required><br>
    ISBN:<input type="text"  id="isbn" required><br>
    作者:<input type="text"  id="zz" required><br>
    出版社:<input type="text"  id="cbx" required><br>
    价格 :<input type="text"  id="jg" required><br>
    <button onclick="tj()">添加</button>

     <script src="axios.min.js"></script>
    <script>
      function tj(){
        var sm = document.getElementById('sm').value;
        var zz = document.getElementById('zz').value;
        var cbx = document.getElementById('cbx').value;
        var jg = document.getElementById('jg').value;
            var isbn = document.getElementById('isbn').value;
        var url = "http://localhost:8080/system/book/add";

        const data = {
          bookName: sm,
          authorName: zz,
          press: cbx,
          price: jg,
          isbn: isbn
        }
        axios.post(url,data,{

        }).then(response => {
          if(response.data.code == 200){
             alert(response.data.message);
             window.location.href = "index.html";
          }else{
             console.log(response);
             alert(response.data.message)
          }
          })
      }

    </script>
  </body>
</html>
